import { fromJS } from 'immutable';
import * as constants from './constants';

const defaultState = fromJS({
	live: {},
	url: '',
	rate: {},
	comment: {},
	liveImg: {},
	localImg: {},
	homeWork: []
});

export default (state = defaultState, action) => {
	switch(action.type) {
		case constants.CHANGE_LIVE:
			return state.set('live', action.value);
		case constants.CHANGE_URL:
			return state.set('url', action.value);
		case constants.CHANGE_RATE:
			return state.set('rate', action.value);
		case constants.CHANGE_COMMENT:
			return state.set('comment', action.value);
		case constants.CHANGE_LIVEIMG:
			return state.set('liveImg', action.value);
		case constants.CHANGE_LOCALIMG:
			return state.set('localImg', action.value);
		case constants.CHANGE_WORKHOME:
			return state.set('homeWork', action.value);
		default:
			return state;
	}
}